package com.mayikt.service.impl;

import com.mayikt.base.BaseApiService;
import com.mayikt.base.BaseResponse;
import com.mayikt.service.WeiXinService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @Name WeiXinServiceImpl
 * @Author 枫火
 * @Date 2021/3/30 20:32
 * @Description
 **/
@RestController
@Slf4j
public class WeiXinServiceImpl extends BaseApiService implements WeiXinService {
    @Override
    public String appInfo(Long userId) {
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
        log.info("TraceId:" + request.getHeader("X-B3-TraceId") + ",spanid:" + request.getHeader("X-B3-SpanId"));
        int j = (int) (1 / userId);
        return "微信接口";
    }


    @Override
    public BaseResponse<String> addApp(String appId, String appPwd) {
        if (StringUtils.isEmpty(appId)) {
            return setResultError("appId不能为空");
        }
        if (StringUtils.isEmpty(appPwd)) {
            return setResultError("appPwd不能为空");
        }
        return setResultSuccess("蚂蚁课堂");
    }
}
